Security News
Highlights from the 2024 Rails Community Survey
A record 2,709 developers participated in the 2024 Ruby on Rails Community Survey, revealing key tools, practices, and trends shaping the Rails ecosystem.
turf-helpers
Advanced tools
Wraps a GeoJSON Geometry in a GeoJSON Feature.
Parameters
geometry
Geometry input geometryproperties
Object propertiesExamples
var geometry = {
"type": "Point",
"coordinates": [
67.5,
32.84267363195431
]
}
var feature = turf.feature(geometry);
//=feature
Returns FeatureCollection a FeatureCollection of input features
Takes coordinates and properties (optional) and returns a new Point feature.
Parameters
coordinates
Array<number> longitude, latitude position (each in decimal degrees)properties
[Object] an Object that is used as the Feature's
propertiesExamples
var pt1 = turf.point([-75.343, 39.984]);
//=pt1
Returns Feature<Point> a Point feature
Takes an array of LinearRings and optionally an Object with properties and returns a Polygon feature.
Parameters
coordinates
Array<Array<Array<number>>> an array of LinearRingsproperties
[Object] a properties objectExamples
var polygon = turf.polygon([[
[-2.275543, 53.464547],
[-2.275543, 53.489271],
[-2.215118, 53.489271],
[-2.215118, 53.464547],
[-2.275543, 53.464547]
]], { name: 'poly1', population: 400});
//=polygon
Returns Feature<Polygon> a Polygon feature
Creates a LineString based on a coordinate array. Properties can be added optionally.
Parameters
coordinates
Array<Array<number>> an array of Positionsproperties
[Object] an Object of key-value pairs to add as propertiesExamples
var linestring1 = turf.lineString([
[-21.964416, 64.148203],
[-21.956176, 64.141316],
[-21.93901, 64.135924],
[-21.927337, 64.136673]
]);
var linestring2 = turf.lineString([
[-21.929054, 64.127985],
[-21.912918, 64.134726],
[-21.916007, 64.141016],
[-21.930084, 64.14446]
], {name: 'line 1', distance: 145});
//=linestring1
//=linestring2
Returns Feature<LineString> a LineString feature
Takes one or more Features and creates a FeatureCollection.
Parameters
features
Array<Feature> input featuresExamples
var features = [
turf.point([-75.343, 39.984], {name: 'Location A'}),
turf.point([-75.833, 39.284], {name: 'Location B'}),
turf.point([-75.534, 39.123], {name: 'Location C'})
];
var fc = turf.featureCollection(features);
//=fc
Returns FeatureCollection a FeatureCollection of input features
Creates a Feature<MultiLineString> based on a coordinate array. Properties can be added optionally.
Parameters
coordinates
Array<Array<Array<number>>> an array of LineStringsproperties
[Object] an Object of key-value pairs to add as propertiesExamples
var multiLine = turf.multiLineString([[[0,0],[10,10]]]);
//=multiLine
Returns Feature<MultiLineString> a MultiLineString feature
Creates a Feature<MultiPoint> based on a coordinate array. Properties can be added optionally.
Parameters
coordinates
Array<Array<number>> an array of Positionsproperties
[Object] an Object of key-value pairs to add as propertiesExamples
var multiPt = turf.multiPoint([[0,0],[10,10]]);
//=multiPt
Returns Feature<MultiPoint> a MultiPoint feature
Creates a Feature<MultiPolygon> based on a coordinate array. Properties can be added optionally.
Parameters
coordinates
Array<Array<Array<Array<number>>>> an array of Polygonsproperties
[Object] an Object of key-value pairs to add as propertiesExamples
var multiPoly = turf.multiPolygon([[[[0,0],[0,10],[10,10],[10,0],[0,0]]]);
//=multiPoly
Returns Feature<MultiPolygon> a multipolygon feature
Creates a Feature<GeometryCollection> based on a coordinate array. Properties can be added optionally.
Parameters
geometries
Array<{Geometry}> an array of GeoJSON Geometriesproperties
[Object] an Object of key-value pairs to add as propertiesExamples
var pt = {
"type": "Point",
"coordinates": [100, 0]
};
var line = {
"type": "LineString",
"coordinates": [ [101, 0], [102, 1] ]
};
var collection = turf.geometrycollection([[0,0],[10,10]]);
//=collection
Returns Feature<GeometryCollection> a geometrycollection feature
This module is part of the Turfjs project, an open source module collection dedicated to geographic algorithms. It is maintained in the Turfjs/turf repository, where you can create PRs and issues.
Install this module individually:
$ npm install turf-helpers
Or install the Turf module that includes it as a function:
$ npm install turf
FAQs
turf geometries
The npm package turf-helpers receives a total of 12,401 weekly downloads. As such, turf-helpers popularity was classified as popular.
We found that turf-helpers demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A record 2,709 developers participated in the 2024 Ruby on Rails Community Survey, revealing key tools, practices, and trends shaping the Rails ecosystem.
Security News
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.